// CalendarDlg.h : header file
//
#include "TechButton.h"
#include "TextButton.h"
#include "systemtray.h"

const UINT	DDF_ERASE		= 0x00,
			DDF_CURRENT		= 0x01,
			DDF_EVENT		= 0x02,
			DDF_SELECTED	= 0x04,
			DDF_NONE		= 0x06;

/////////////////////////////////////////////////////////////////////////////
struct DragDropStructure {
	DragDropStructure(void) : day(0), month(0), isButtonDown(false), isDragging(false)
	{}

// attributes
	unsigned int day, month;
	bool isButtonDown, isDragging;
public:
	BOOL Restore(void);
	BOOL Initiate(void);
private:
	HCURSOR m_hOldCursor;
	HCURSOR m_hCursor;
};

/////////////////////////////////////////////////////////////////////////////
struct StatusBarStructure {
	StatusBarStructure(void) : cx(0), y(0), cy(0), x(0) {}
	int cx, y, x, cy;
};

//#include "cimage\cimage.h"
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
// CCalendarDlg dialog
#define WM_SETUPTRAYICON WM_USER + 110


class CCalendarDlg : public CDialog
{
// Construction
public:
	void SetUpTrayIcon(bool bEnable);
	bool m_bShowCalendar;

	BOOL SetWindowText(LPCTSTR lpszString);
	BOOL SetStatusBarText(LPCSTR lpszStr);
	BOOL SetStatusBarText(UINT);
	BOOL DrawPaperFrame(void);
	BOOL GetDayBounds( int month, int day, RECT *rect );
	BOOL DrawDay( int month, int day, UINT uiFlags = DDF_NONE);
	~CCalendarDlg(void);
	void GetNextMonth( int &month );
	void GetCell( CPoint *point, __Cell *pCell);
	
	CCalendarDlg(CWnd* pParent = NULL);	// standard constructor
		
// Dialog Data
	//{{AFX_DATA(CCalendarDlg)
	enum { IDD = IDD_CALENDAR_DIALOG };
	CTextButton	m_menuButton;
	CTechButton	m_btnMinimize;
	CTechButton	m_btnOk;
	CTechButton	m_btnAppAbout;
	CTechButton	m_btnNext;
	CTechButton	m_btnPrev;
	//}}AFX_DATA

	virtual int DoModal();

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CCalendarDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	virtual void PreSubclassWindow();
	//}}AFX_VIRTUAL

// Implementation
protected:
	bool m_bDisplayWeekDays;
	void applyOptions();
	CSystemTray m_TrayIcon;

	HCURSOR m_hHandCursor;
	CFont m_yearFont;
	void RecalculateDays(bool);
	afx_msg BOOL OnQueryNewPalette();
	afx_msg void OnPaletteChanged(CWnd* pFocusWnd);

	CPalette* SetPalette(CPalette* pPalette);
	CPalette* m_pPalette;

	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CCalendarDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnDestroy();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
	afx_msg UINT OnNcHitTest( CPoint point );
	afx_msg void OnNextScroll();
	afx_msg void OnPrevScroll();
	afx_msg void OnAppAbout();
	afx_msg void OnAbout();
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnMinimize();
	afx_msg void OnMenuButton();
	afx_msg void OnChooseDay();
	afx_msg void OnOptions();
	afx_msg void OnSelectUser();
	afx_msg void OnExport();
	afx_msg void OnImport(void);
	afx_msg void OnUpdateSelectUser(CCmdUI* pCmdUI);
	afx_msg void OnUpdateProfiles(CCmdUI* pCmdUI);
	afx_msg void OnProfiles();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMenuSelect( UINT nItemID, UINT nFlags, HMENU hSysMenu );
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	virtual void OnCancel();
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	afx_msg void OnSetUpTrayIcon(WPARAM wParm, LPARAM lParm);
	//}}AFX_MSG

	afx_msg void OnSizing( UINT nSide, LPRECT lpRect );
	afx_msg void OnSysTrayShow();
	afx_msg void OnSysTrayClose();

	DECLARE_MESSAGE_MAP()

private:
	void DrawLandscapePart( int month );
	CBitmap m_backgroundBitmap;
	CDC m_backgroundDC;
	StatusBarStructure m_statusbar;
	bool ShowHintWindow(int x, int y, bool bUpdate, bool bAlign);
	bool ChangeSelectionPosition( unsigned int month, unsigned int day );
	bool IsCursorOnCell(CPoint &point, __Cell &cell);
	DragDropStructure dragdrop;
	BOOL Initialize(CTime &time);
//	CPalette m_Pal;
	HBRUSH m_hbrPaper;
	BOOL DrawMonthes(void);
	HWND m_hEBWnd;
//	BOOL m_bIsSecondRaw;
	BOOL ScaleWindows(void);
	UINT m_uiFirstMonthDraw;
	UINT m_uiCurDaySelection;
	UINT m_uiTextOffset;
	UINT m_uiMonthBoxHeight;
	UINT m_uiMonthBoxWidth;
	UINT m_uiFullMonthBoxHeight;
	UINT m_uiFullMonthBoxWidth;
	UINT m_uiDayBoxHeight;
	UINT m_uiDayBoxWidth;
	UINT m_uiDaysXOffset;
	CFont m_txtFont;
	CRgn m_WindowRgn;
	LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
	CBitmap m_VirtualBitmap;
	CDC m_VirtualDC;
	CToolTipCtrl m_ToolTip;
//	UINT m_iCurSelDay;
	CTime m_Time;
	CPen *eventPen;
	CPen *curDayPen;
	CPen *curSelPen;
	CPen erasePen;

//	CImage* m_pBackgroundImage;
//	UINT m_uiMonth;
};

